﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Markup;
using Kokomo.Environment.Services;
using System.Windows.Media;

namespace Kokomo.Environment.Services
{
	[MarkupExtensionReturnType(typeof(ImageSource))]
	public class ImageExtension : MarkupExtension
	{
		public ImageExtension()
		{
		}

		public ImageExtension(
			string imageKey
			)
		{
			this.ImageKey = imageKey;
		}

		public ImageExtension(
			string imageKey,
			IImageProvider imageProvider
			)
		{
			this.ImageKey = imageKey;
			this.ImageProvider = imageProvider;
		}

		public override object ProvideValue(IServiceProvider serviceProvider)
		{
			return ImageHelper.DetermineImageSource(
				this.ImageKey,
				this.ImageProvider
				);
		}

		[ConstructorArgument("imageKey")]
		public string ImageKey { get; set; }

		[ConstructorArgument("imageProvider")]
		public IImageProvider ImageProvider { get; set; }
	}
}
